<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // ES5实例化对象
        function phone(brand, price) {
            this.brand = brand;
            this.price = price;
        }
        //添加方法
        phone.prototype.call = function() {
                console.log('我可以打电话和发短信!');
            }
            // 实例化对象
        let Huawei = new phone('华为', 5599);
        Huawei.call();
        console.log(Huawei);

        //class实例化对象
        class shouji {
            //构造方法，名字不能进行修改
            constructor(brand, price) {
                this.brand = brand;
                this.price = price;
            }

            call() {
                console.log('我可以刷视频！');
            }
        }
        let xiaomi = new shouji('小米', 2999);
        xiaomi.call();
        console.log(xiaomi);
    </script>
</body>

</html>